<?php
/**
 * Created by PhpStorm.
 * User: gzc0918
 * Date: 2021-08-08
 * Time: 23:27
 */

namespace IMooc;


class Config implements \ArrayAccess
{
    protected $path;//配置文件所在的目录
    protected $configs = array();
    function __construct($path)
    {
        $this->path = $path;
    }
    function offsetGet($key)
    {
        if(!$this->offsetExists($key))
        {
            $file_path = $this->path.'/'.$key.'.php';
            $config = require $file_path;
            $this->configs[$key] = $config;
        }
        return $this->configs[$key];
    }
    function offsetSet($key, $value)
    {
        // TODO: Implement offsetSet() method.
    }
    function offsetExists($key)
    {
        return isset($this->configs[$key]);
    }
    function offsetUnset($key)
    {
        unset($this->configs[$key]);
    }
}